//
//  ProgramModel.m
//  RainbowFM
//
//  Created by Kratos on 14/12/24.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "ProgramAPI.h"

#import "AFAppDotNetAPIClient.h"


@implementation ProgramAPI

-(void)fetchProgramListWithVip:(NSString *)vip
                   currentPage:(NSString *)currentPage
                      pageSize:(NSString *)pageSize
                        result:(void (^)(NSArray *list, NSString *msg))res
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    if (vip) {
        [params setObject:@"1" forKey:@"vip"];
    }else{
        [params setObject:@"" forKey:@"vip"];
    }
    
    
    if (!currentPage || !pageSize) {
        res(nil,@"缺少 当前页 或 每页条数");
        return;
    }else
    {
        [params setObject:currentPage forKey:@"currentPage"];
        [params setObject:pageSize forKey:@"pageSize"];
    }
    
    [[AFAppDotNetAPIClient sharedClient] POST:VIDEO_BASE_URL
                                   parameters:@{@"serviceName":@"video_queryAct_req",
                                                @"callType":@"002",
                                                @"params":params
                                                }
                                      success:^(NSURLSessionDataTask *task, id responseObject) {
                                          if ([responseObject[@"returnCode"] isEqualToString:@"000000"]) {
                                              res(responseObject[@"result"][@"list"],nil);
                                          }
                                          else{
                                              res(nil,responseObject[@"errorMsg"]);
                                          }
                                          
                                      }
                                      failure:^(NSURLSessionDataTask *task, NSError *error) {
                                          res(nil,@"erroe for fetchProgramList");
                                      }];
}

@end


